//
//  UIDeviceOrientation+Ext.swift
//  TTCOM-iOS
//
//  Created by Toj on 10/26/22.
//

import UIKit

// 屏幕旋转方向
public enum DODirection {
    case left
    case right
    case up
}

public extension UIDeviceOrientation {
    var do_directionString: String {
        return isLandscape ? "landscape" : "portrait"
    }
    
    var do_isLandscape: Bool? {
        switch self {
        case .landscapeLeft, .landscapeRight:
            return true
        case .portrait:
            return false
        default:
            return nil
        }
    }
    
    var do_isPortrait: Bool? {
        switch self {
        case .landscapeLeft, .landscapeRight:
            return false
        case .portrait:
            return true
        default:
            return nil
        }
    }
    
    var do_direction: DODirection? {
        switch self {
        case .landscapeLeft:
            return .left
        case .landscapeRight:
            return .right
        case .portrait:
            return .up
        default:
            return nil
        }
    }
    
    var do_toInterfaceOrientation: UIInterfaceOrientation {
        switch self {
        case .landscapeLeft:
            return .landscapeRight
        case .landscapeRight:
            return .landscapeLeft
        default:
            return .portrait
        }
    }
}
